﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Webshop20.Domain.Catalog.Core;
using Webshop20.Domain.Catalog.Translations.CatalogToOrders;
using Webshop20.Domain.Orders.Core;

namespace Webshop20.Domain.Catalog.Translations.CatalogToOrders
{
    public class OrderTranslator : IOrderTranslator 
    {
        public IList<Position> convertCartItemsToPositions(ShoppingCart cart)
        {
            IList<Position> positions = new List<Position>();

            int number = 1;
            foreach(var cartItem in cart.CartItems)
            {
                positions.Add(new Position(number, cartItem.Product, cartItem.Quantity, cartItem.Product.NetPrice));
                number++;
            }

            return positions;
        }
    }
}